package com.tuanzi.loan.web.bean.statistics;

import com.base.common.log.LogService;
import com.tuanzi.loan.business.service.statistics.CreditCardManagerDataStatService;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.vo.request.statistics.CreditCardManagerDataStatSearchRequest;
import com.tuanzi.loan.vo.response.statistics.CreditCardManagerDataStatSearchResponse;
import com.tuanzi.loan.web.configuration.JSFListingBean;
import com.tuanzi.loan.web.lazy.statistics.CreditCardManagerDataStatLazyModel;
import com.tuanzi.server.loan_base.util.DateUtils;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.faces.bean.ViewScoped;
import java.text.ParseException;
import java.text.SimpleDateFormat;

/**
* @Description:    信用卡管家综合
* @Author:         xionghao
* @CreateDate:
*/

@Debug
@Data
@Component
@ViewScoped
@EqualsAndHashCode(callSuper = true)
public class CreditCardManagerDataStatBean extends
        JSFListingBean<CreditCardManagerDataStatSearchRequest,CreditCardManagerDataStatSearchResponse>{
    private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    @Autowired
    private CreditCardManagerDataStatService service;

    @PostConstruct
    public void init(){
        initLazyModel();
    }

    public void initLazyModel(){
        $=new CreditCardManagerDataStatSearchRequest();
        try {
            $.setStartDate(sdf.parse(DateUtils.getDateBeforeDays(1)));
            $.setEndDate(sdf.parse(DateUtils.getCurrentDate()));
        } catch (ParseException e) {
            LogService.error("日期类型转换异常",e);
        }
        lazyDataModel = new CreditCardManagerDataStatLazyModel($);
    }

}
